<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
  <table border="1">
    <caption>员工列表</caption>
    <tr><th>编号</th><th>姓名</th>
      <th>工资</th><th>工作</th><th>操作</th></tr>
    <!--i代表当前遍历数组中对象的下标-->
    <tr v-for="(e,i) in arr">
      <td>{{i+1}}</td>
      <td>{{e.name}}</td>
      <td>{{e.salary}}</td>
      <td>{{e.job}}</td>
      <!--i代表点击删除时对应的这一行的下标-->
      <td><input type="button" value="删除" @click="del(i)"></td>
    </tr>
  </table>
  <input type="text" placeholder="姓名" v-model="emp.name">
  <input type="text" placeholder="工资" v-model="emp.salary">
  <input type="text" placeholder="工作" v-model="emp.job">
  <input type="button" value="添加员工" @click="f()">
</div>
<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
<script>
  let v = new Vue({
    el:"body>div",
    data:{
      arr:[],
      emp:{name:"",salary:"",job:""}
    },
    methods:{
      f(){
        //往数组中添加对象
        v.arr.push({name:v.emp.name,
          salary:v.emp.salary,
        job:v.emp.job});
      },
      del(i){
        //从数组中删除对象 splice(删除的位置,删除的数量)
        v.arr.splice(i,1);
      }
    }
  })
</script>
<script>

</script>
</body>
</html>